<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/base/jsp/include.jsp"%>
<script type="text/javascript">
	var id = '${id}';
	var grid;
	var topicFun = function(id){
		var dialog = parent.sy.modalDialog({
			title : '晒一晒回复',
			width : 800,
			height : 600,
			url : sy.contextPath + '/go?path=share/reply&id='+id
		});
	};
	var visitFun = function(id){
		var dialog = parent.sy.modalDialog({
			title : '访问',
			width : 450,
			height : 600,
			url : sy.contextPath + '/go?path=share/visit&id='+id
		});
	};
	$(function() {
		grid = $('#grid').datagrid({
			url : sy.contextPath + '/shareTopic/list?id='+id,
			pagination : true,
			frozenColumns : [ [ {
				width : $(this).width() * 0.3,
				title : '名称',
				align : 'center',
				field : 'info',
				formatter : function(v,r,i){
					return UT.addTitle(v);
				}
			} ] ],
			columns : [ [{
				width : $(this).width() * 0.05,
				title : '图片',
				field : 'img',
				align : 'center',
				formatter : function(v,r,i){
					return po.showImg(v,18,18);
				}
			
			},{
				width : $(this).width() * 0.3,
				title : '发表时间',
				field : 'createTime',
				align : 'center'
			},{
				width : $(this).width() * 0.1,
				title : '回复',
				field : 'reply',
				align : 'center',
				formatter : function(v,r,i){
					if (v > 0){
						var str = '<a href=\'javascript:void(0);\' onclick=\'topicFun(\"'+r.id+'\")\'>'+v+'</a>';
						return str;
					}else
						return v;
				}
			},{
				width : $(this).width() * 0.1,
				title : '访问',
				field : 'visit',
				align : 'center',
				formatter : function(v,r,i){
					if (v > 0){
						var str = '<a href=\'javascript:void(0);\' onclick=\'visitFun(\"'+r.id+'\")\'>'+v+'</a>';
						return str;
					}else
						return v;
				}
			},{
				width : $(this).width() * 0.1,
				title : '上线',
				field : 'isShow',
				align : 'center',
				formatter : function(v,row,i){
					switch (v) {
					case 0:
						return '<a href="javascript:void(0);" onclick="show(1,\''+row.id+'\')" ><img src="base/images/no.png" alt="点击启用" > </img></a>';
					case 1:
						return '<a href="javascript:void(0);" onclick="show(0,\''+row.id+'\')" ><img src="base/images/yes.png"  alt="点击禁用" > </img></a>';
					}
				}
			}
			]]
		});
	});
	
	function show(type,id) {
		if (type == 1) {
			parent.$.messager.confirm('询问',"确定恢复该参与？", function(r) {
				if (r) {
					
					var data = {
						id : id,
						isShow : 1
					};
					SaveData(data);
				}
			});
		} else{
			parent.$.messager.confirm('询问',"确定删除该参与？", function(r) {
				if (r) {
					var data = {
						id : id,
						isShow : 0
					};
					SaveData(data);
				}
			});
		}
	}
	function SaveData(data) {
		var url = sy.contextPath + '/shareTopic/save';
		$.post(url, data, function() {
			grid.datagrid('reload');
		}, 'json');
	}
</script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid" data-options="fit:true,border:false"></table>
	</div>
</body>
</html>